package com.security.door.controller;

import com.security.door.utils.AuthJwt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
public class BaseController {
    @Autowired
    HttpServletResponse httpServletResponse;
    @Autowired
    HttpServletRequest httpServletRequest;


    protected String getUserName() {
        String token = httpServletRequest.getHeader("token");
        if (null == token)
            token = httpServletRequest.getParameter("token");
        return AuthJwt.getUserName(token);
    }
}
